package com.zhiyou100.crm.servlet.role;

import java.io.IOException;
import java.sql.Timestamp;
import java.time.LocalDateTime;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zhiyou100.crm.service.RoleService;
import com.zhiyou100.crm.service.impl.RoleServiceImpl;
import com.zhiyou100.crm.util.AdminBaseServlet;
import com.zhiyou100.crm.util.Role;

/**
 * 删除角色
 */
@WebServlet("/role/remove")
public class RemoveServlet extends AdminBaseServlet {
	private static final long serialVersionUID = 1L;
	RoleService roleService=new RoleServiceImpl();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		int roleId = Integer.parseInt(request.getParameter("id"));
		int a = roleService.deleteRole(roleId);
		if(a>0){
			response.sendRedirect(request.getContextPath() + "/role/list");
		}else {
			request.getRequestDispatcher("/WEB-INF/view/role/list.jsp").forward(request, response);
		}
	}

}
